package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceOrdernurse;
import com.ruoyi.service.service.IServiceOrdernurseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单护士对应Controller
 * 
 * @author ZDL
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/service/ordernurse")
public class ServiceOrdernurseController extends BaseController
{
    @Autowired
    private IServiceOrdernurseService serviceOrdernurseService;

    /**
     * 查询订单护士对应列表
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceOrdernurse serviceOrdernurse)
    {
        startPage();
        List<ServiceOrdernurse> list = serviceOrdernurseService.selectServiceOrdernurseList(serviceOrdernurse);
        return getDataTable(list);
    }

    /**
     * 导出订单护士对应列表
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:export')")
    @Log(title = "订单护士对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceOrdernurse serviceOrdernurse)
    {
        List<ServiceOrdernurse> list = serviceOrdernurseService.selectServiceOrdernurseList(serviceOrdernurse);
        ExcelUtil<ServiceOrdernurse> util = new ExcelUtil<ServiceOrdernurse>(ServiceOrdernurse.class);
        util.exportExcel(response, list, "订单护士对应数据");
    }

    /**
     * 获取订单护士对应详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:query')")
    @GetMapping(value = "/{ordernurseId}")
    public AjaxResult getInfo(@PathVariable("ordernurseId") Long ordernurseId)
    {
        return success(serviceOrdernurseService.selectServiceOrdernurseByOrdernurseId(ordernurseId));
    }

    /**
     * 新增订单护士对应
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:add')")
    @Log(title = "订单护士对应", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceOrdernurse serviceOrdernurse)
    {
        return toAjax(serviceOrdernurseService.insertServiceOrdernurse(serviceOrdernurse));
    }

    /**
     * 修改订单护士对应
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:edit')")
    @Log(title = "订单护士对应", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceOrdernurse serviceOrdernurse)
    {
        return toAjax(serviceOrdernurseService.updateServiceOrdernurse(serviceOrdernurse));
    }

    /**
     * 删除订单护士对应
     */
    @PreAuthorize("@ss.hasPermi('service:ordernurse:remove')")
    @Log(title = "订单护士对应", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ordernurseIds}")
    public AjaxResult remove(@PathVariable Long[] ordernurseIds)
    {
        return toAjax(serviceOrdernurseService.deleteServiceOrdernurseByOrdernurseIds(ordernurseIds));
    }
}
